Pixel Format
kCVPixelFormatType
概要
具体的な値も含めたリストをみたければ Microsoft の doc の方が良い。
指定の例
code:swift
let output = AVCaptureVideoDataOutput()
// 利用可能なPixelFormatは、avialableVideoPixelFormatTypes() で確認できる
// print(output.avialableVideoPixelFormatTypes())
output.videoSettings = [
kCVPixelBufferPixelFormatTypeKey: NSNumber(value: kCVPixelFormatType_32BGRA)
YCbCr 形式で受け取りつつシェーダで色空間を変換するという方法も取れる。 手軽さでは videoSettings で設定する方が良いけれど、パフォーマンスは特に計測していないので、シェーダを利用した変換の方が優れているということはありそう。
code:swift
var pixelBufferPool: CVPixelBufferPool? = nil
kCVPixelBufferPixelFormatTypeKey: NSNumber(value: kCVPixelFormatType_32BGRA),
]
CVPixelBufferPoolCreate(nil, nil, attributes as CFDictionary?, &pixelBufferPool)
MTLPixelFormat
Metal を利用する場合はまた別の表現がされている。 参考